<template>
  <div style="padding: 20px">
    <Select v-model="select_type" style="width:200px;">
      <Option value="all">全部</Option>
      <Option value="community">社区</Option>
      <Option value="cun">存</Option>
    </Select>
    <DatePicker v-model="Time" type="datetimerange" placeholder="选择查询时间段" style="width: 300px;margin-bottom: 20px;margin-left: 10px;margin-right: 10px"></DatePicker>
    <Button type="info" @click="init" :loading="tableLoading">查询</Button>
    <Table :columns="columns" :data="data" :loading="tableLoading"></Table>
  </div>
</template>
<script>
import { datetime2str, findPeopleOperateLogNumList } from '../../api/eventlist'

export default {
  name: 'index',
  data () {
    return {
      tableLoading: false,
      Time: [],
      select_type: 'all',
      columns: [
        {
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '区县',
          key: 'name'
        },
        {
          title: '全区总人数',
          key: 'z_num'
        },
        {
          title: '全区总人数（去重）',
          key: 'zqc_num'
        },
        {
          title: '更新总人数',
          key: 'all_num'
        },
        {
          title: '新增人数',
          key: 'insert_num'
        },
        {
          title: '新增占比',
          key: 'insert_zb'
        },
        {
          title: '更新人数',
          key: 'update_num'
        },
        {
          title: '更新占比',
          key: 'update_zb'
        }
      ],
      data: []
    }
  },
  methods: {
    init () {
      let data = {
        select_type: this.select_type
      }
      if (this.Time.length !== 0) {
        data.create_time_begin = datetime2str(this.Time[0])
        data.create_time_end = datetime2str(this.Time[1])
      }
      this.tableLoading = true
      findPeopleOperateLogNumList(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.data = ret.data.data
          this.tableLoading = false
        } else {
          this.$Notice.error({ title: '查询失败', desc: ret.data.errmsg })
        }
      })
    }
  },
  mounted () {
    this.init()
  }
}
</script>
<style scoped>

</style>
